/***********************************************************************
 * Module:  RandomUtil.java
 * Author:  gongfp
 * Purpose: Defines the Class RandomUtil
 ***********************************************************************/

package com.hsyt.pfc.support.util;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * @Description: 随机数生成工具类
 * @ClassName: RandomUtil.java
 * @Package: com.hundsun.rmc.oauth.msg
 * @Author: wangze@hsyuntai.com
 * @Date: 2015年3月5日 上午9:01:17
 * @Copyright: 版权归 Hundsun 所有 <ModifyLog>
 * @ModifyContent:
 * @Author:
 * @Date: </ModifyLog>
 */
public class RandomUtil {

    private static String[] numbers = new String[]{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "1", "2",
            "3", "4", "5", "6", "7", "8", "9"};

    /**
     * 生成随机数，由size决定随机数的位数，最高不超过20位
     *
     * @pdOid 89b4fb42-dcaa-4179-8be4-85f0bef4ae33
     */
    public static String random(int size) {
        List<String> list = Arrays.asList(numbers);
        Collections.shuffle(list);
        StringBuffer result = new StringBuffer();
        for (int i = 0; i < size; i++) {
            result.append(list.get(i));
        }
        return result.toString();
    }
}